package com.fr.report.cellElement.core;

import com.fr.base.FRContext;
import com.fr.base.XMLable;
import com.fr.base.core.list.IntList;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.data.TableData;
import com.fr.data.TableDataException;
import com.fr.report.script.Calculator;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

public abstract class RecordGrouper
  implements XMLable
{
  public static final String XML_TAG = "RG";

  public Group[] group(TableData paramTableData, int paramInt, int[] paramArrayOfInt, Calculator paramCalculator)
  {
    if (paramArrayOfInt == null)
      try
      {
        paramArrayOfInt = IntList.range(paramTableData.getRowCount());
      }
      catch (TableDataException localTableDataException)
      {
        FRContext.getLogger().log(Level.WARNING, localTableDataException.getMessage(), localTableDataException);
      }
    if (paramInt == -1)
    {
      Group[] arrayOfGroup = new Group[paramArrayOfInt.length];
      for (int i = 0; i < paramArrayOfInt.length; ++i)
        arrayOfGroup[i] = new Group(new Integer(paramArrayOfInt[i] + 1), new int[] { paramArrayOfInt[i] });
      return arrayOfGroup;
    }
    return new Group[0];
  }

  public Iterator groupIterator(TableData paramTableData, int paramInt, int[] paramArrayOfInt, Calculator paramCalculator)
  {
    return Arrays.asList(group(paramTableData, paramInt, paramArrayOfInt, paramCalculator)).iterator();
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    return super.clone();
  }
}